package org.baojie.raft.connector;

import org.baojie.raft.node.NodeName;

public class ChannelKey {

    private final NodeName remote;

    public ChannelKey(NodeName remote) {
        this.remote = remote;
    }

    public NodeName getRemote() {
        return remote;
    }

    @Override
    public boolean equals(Object obj) {
        if (null == obj) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (obj instanceof ChannelKey) {
            ChannelKey tmp = (ChannelKey) obj;
            if (!this.remote.equals(tmp.remote)) {
                return false;
            }
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + remote.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "ChannelKey{" +
                "remote=" + remote +
                '}';
    }
}
